/**
 * 
 */
package com.igatewebsol.action;

import java.io.File;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.ServletRequestAware;

import com.igatewebsol.actionforms.HotelAccomdationCategoryBean;
import com.igatewebsol.actionforms.HotelAccomdationTypeBean;
import com.igatewebsol.actionforms.HotelCurrencyTypeBean;
import com.igatewebsol.actionforms.HotelGroupBean;
import com.igatewebsol.actionforms.HotelMainBean;
import com.igatewebsol.actionforms.HotelStarRatingAwardBean;
import com.igatewebsol.common.HotelProjectUitls;
import com.igatewebsol.service.HotelService;
import com.opensymphony.xwork2.ActionSupport;

/**
 * @author R
 * 
 */
public class HotelRegisterAction extends ActionSupport implements ServletRequestAware {

	/**
	 * 
	 */
	public Logger logger=Logger.getLogger(HotelRegisterAction.class);
	private static final long serialVersionUID = 1L;
	private HotelMainBean hMainForm = new HotelMainBean();
	private HotelGroupBean hGroupBean = new HotelGroupBean();
	private HotelService hotelService = new HotelService();
	private ArrayList<HotelAccomdationCategoryBean> haccomdCategoryBeanList = new ArrayList<HotelAccomdationCategoryBean>();
	private ArrayList<HotelStarRatingAwardBean> hAwardBeanList = new ArrayList<HotelStarRatingAwardBean>();
	private ArrayList<HotelGroupBean> hotelgrpList = new ArrayList<HotelGroupBean>();
	private ArrayList<HotelCurrencyTypeBean> hotelCurrencyTypeList = new ArrayList<HotelCurrencyTypeBean>();
	private ArrayList<HotelAccomdationTypeBean> hotelAccodTypeList=new ArrayList<HotelAccomdationTypeBean>();
	private ArrayList<String> hotelreservefromtimeList=new ArrayList<String>();
	private ArrayList<String>hotelreserveendtimeList =new ArrayList<String>();
	private ArrayList<String>hotelcancelTimeList=new ArrayList<String>();
	private HttpServletRequest servletRequest; 
	private File hotelpreviewImage;
	private String hotelpreviewImageContentType;
	private String hotelpreviewImageFileName;

	public String hotelregisterpopulate() {
		logger.info("Populating the Hotel Register Details");
		String username = "admin";
		hotelgrpList = hotelService.getHotelGroupByUserId(username);
		hotelCurrencyTypeList=hotelService.getHotelCurrencyTypeList();
		hotelAccodTypeList=hotelService.gethotelAccodTypeList();
		haccomdCategoryBeanList=hotelService.getHotelAccodCategoryList();
		hotelreservefromtimeList=HotelProjectUitls.getTimeList();
		hotelreserveendtimeList=HotelProjectUitls.getTimeList();
		hotelcancelTimeList=HotelProjectUitls.getTimeList();
		return SUCCESS;
	}

	public String createhotelgroup() {
		logger.info("Its creating Group method");
		hGroupBean.setHotelgroupcreatedById("admin");
		int insertcount = hotelService.createhotelgroup(hGroupBean);
		if (insertcount > 0) {
			return SUCCESS;
		} else {
			return ERROR;
		}

	}
	
	public String addhotelregisterdetails(){
		logger.info("In addhotelregisterdetails Method");
		
		/*String filePath = servletRequest.getSession().getServletContext().getContextPath();
        System.out.println("Server path:" + filePath);*/
      /*  File fileToCreate = new File(filePath, this.hotelpreviewImageFileName);

        FileUtils.copyFile(this.hotelpreviewImage, fileToCreate);*/
		
		int insertcount=hotelService.addhotelregisterdetails(hMainForm);
		
		/*if (insertcount > 0) {
			return SUCCESS;
		} else {
			return ERROR;
		}*/
		return ERROR;
	}

	public String createHotelCurrencyType() {

		int insertcount = hotelService.createHotelCurrencyType(hMainForm.gethCurrencyTypeBean());
		if (insertcount > 0) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}

	public HotelService getHotelService() {
		return hotelService;
	}

	public void setHotelService(HotelService hotelService) {
		this.hotelService = hotelService;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String execute() {
		return SUCCESS;
	}


	public ArrayList<HotelAccomdationCategoryBean> getHaccomdCategoryBeanList() {
		return haccomdCategoryBeanList;
	}


	public HotelMainBean gethMainForm() {
		return hMainForm;
	}


	public void sethAwardBeanList(
			ArrayList<HotelStarRatingAwardBean> hAwardBeanList) {
		this.hAwardBeanList = hAwardBeanList;
	}


	public void sethMainForm(HotelMainBean hMainForm) {
		this.hMainForm = hMainForm;
	}

	/**
	 * @param hGroupBean
	 *            the hGroupBean to set
	 */
	public void sethGroupBean(HotelGroupBean hGroupBean) {
		this.hGroupBean = hGroupBean;
	}

	/**
	 * @return the hGroupBean
	 */
	public HotelGroupBean gethGroupBean() {
		return hGroupBean;
	}

	public ArrayList<HotelGroupBean> getHotelgrpList() {
		return hotelgrpList;
	}

	public void setHotelgrpList(ArrayList<HotelGroupBean> hotelgrpList) {
		this.hotelgrpList = hotelgrpList;
	}

	public ArrayList<HotelStarRatingAwardBean> getHAwardBeanList() {
		return hAwardBeanList;
	}

	public void setHAwardBeanList(
			ArrayList<HotelStarRatingAwardBean> awardBeanList) {
		hAwardBeanList = awardBeanList;
	}

	public HotelMainBean getHMainForm() {
		return hMainForm;
	}

	public void setHMainForm(HotelMainBean mainForm) {
		hMainForm = mainForm;
	}

	public HotelGroupBean getHGroupBean() {
		return hGroupBean;
	}

	public ArrayList<HotelCurrencyTypeBean> getHotelCurrencyTypeList() {
		return hotelCurrencyTypeList;
	}

	public void setHotelCurrencyTypeList(
			ArrayList<HotelCurrencyTypeBean> hotelCurrencyTypeList) {
		this.hotelCurrencyTypeList = hotelCurrencyTypeList;
	}

	public void setHGroupBean(HotelGroupBean groupBean) {
		hGroupBean = groupBean;
	}

	public ArrayList<HotelAccomdationTypeBean> getHotelAccodTypeList() {
		return hotelAccodTypeList;
	}

	public void setHotelAccodTypeList(
			ArrayList<HotelAccomdationTypeBean> hotelAccodTypeList) {
		this.hotelAccodTypeList = hotelAccodTypeList;
	}

	public ArrayList<String> getHotelreservefromtimeList() {
		return hotelreservefromtimeList;
	}

	public void setHotelreservefromtimeList(
			ArrayList<String> hotelreservefromtimeList) {
		this.hotelreservefromtimeList = hotelreservefromtimeList;
	}

	public ArrayList<String> getHotelreserveendtimeList() {
		return hotelreserveendtimeList;
	}

	public void setHotelreserveendtimeList(ArrayList<String> hotelreserveendtimeList) {
		this.hotelreserveendtimeList = hotelreserveendtimeList;
	}

	public static long getSerialVersionUID() {
		return serialVersionUID;
	}

	public void setHaccomdCategoryBeanList(
			ArrayList<HotelAccomdationCategoryBean> haccomdCategoryBeanList) {
		this.haccomdCategoryBeanList = haccomdCategoryBeanList;
	}

	public ArrayList<String> getHotelcancelTimeList() {
		return hotelcancelTimeList;
	}

	public void setHotelcancelTimeList(ArrayList<String> hotelcancelTimeList) {
		this.hotelcancelTimeList = hotelcancelTimeList;
	}

	 @Override
	    public void setServletRequest(HttpServletRequest servletRequest) {
	        this.servletRequest = servletRequest;
	 
	    }

	public File getHotelpreviewImage() {
		return hotelpreviewImage;
	}

	public void setHotelpreviewImage(File hotelpreviewImage) {
		this.hotelpreviewImage = hotelpreviewImage;
	}

	public String getHotelpreviewImageContentType() {
		return hotelpreviewImageContentType;
	}

	public void setHotelpreviewImageContentType(String hotelpreviewImageContentType) {
		this.hotelpreviewImageContentType = hotelpreviewImageContentType;
	}

	public String getHotelpreviewImageFileName() {
		return hotelpreviewImageFileName;
	}

	public void setHotelpreviewImageFileName(String hotelpreviewImageFileName) {
		this.hotelpreviewImageFileName = hotelpreviewImageFileName;
	}

	public HttpServletRequest getServletRequest() {
		return servletRequest;
	}


}
